<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="java.util.List"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="javax.jdo.PersistenceManager"%>
<%@ page import="com.anduinslegacy.armory.Character"%>
<%@ page import="com.anduinslegacy.datastore.PMF"%>
<%@ page import="javax.jdo.Query" %>

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>Anduin's Legacy Applications</title>
	<link href="../css/style1.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="ev_bg">
	<div id="everything">
	    <div id="header">
	      <h1>Data Store Basics</h1>
	    </div>
	    <div id="middle">
	    	<div id="left_column">    
				<jsp:include page="navigation" />
				<jsp:include page="../includes/poweredby" />
	      	</div>     
	      	<div id="middle_column">		  
				<div class="date_break">News.</div>		  
	           		<div class="post">
			            <h1>Goals:</h1>            
			            <div class="post_body" id="post1" >              
			              <p>
			              	For this page I would like to accomplish the following:<br />
				              <UL>
				              	<li>Save a new object to the data store.</li>
				              	<li>Select that object and display its data.</li>
				              	<li>Update that object and save the changes to the data store.</li>
				              	<li>Delete that object from the data store.</li>
				              </UL>
			              </p>          
			            </div>
						<jsp:include page="../includes/postedby" />
	          		</div>
	           <div class="post">
	            <h1>???</h1>            
	            <div class="post_body" id="post2" >              
	              <p>
	              <% 
	              	if (request.getParameter("show") != null) {
	            	  if (request.getParameter("show").equals("all")){
	  					PersistenceManager pm = PMF.get().getPersistenceManager();
						String query = "select from " + Character.class.getName();	 
					    List<Character> character = (List<Character>) pm.newQuery(query).execute();
					    if (character.isEmpty()) {%>
					    	The datastore is empty!
					    <%}
					    else {
					    	for (Character c : character) { %>
					    		<%=c.getKey().toString()%> | <%=c.getToon() %> | <%=c.getPoints() %> |<br />				    							    		
					    	<%}	
					    }
	            	  }
	            	 }
	            	%>
	              </p>          
	            </div>
				<jsp:include page="../includes/postedby" />
	          </div>
	        </div>        
		    <div id="right_column">         
	          <div class="box">
				<div id="navigation">
					<a href="#">Create.</a>
					<form action="/bob">					
						<input type="text" name="name" value="Woa" />
						<input type="text" name="points" value="9000" />
						<input type="hidden" name="show" value="all" >
						<input type="submit" value="Create Character"/>
					</form>				
				</div>
	 		  </div>
	          <div class="box">
				<div id="navigation">
					<a href="#">Select/Display.</a>				
					<form action="test.jsp">
						<input type="submit" value="Show all" />
						<input type="hidden" name="show" value="all" >
					</form>					
					<form action="test.jsp">					
						<input type="submit" value="Hide all" />
						<input type="hidden" name="hide" value="hide" >
					</form>
				</div>
	 		  </div>
	          <div class="box">
				<div id="navigation">
					<a href="#">Update/Save.</a>				
				</div>
	 		  </div>
	          <div class="box">
				<div id="navigation">
					<a href="#">Delete.</a>				
				</div>
	 		  </div>
		  </div>       
	    </div>
	<jsp:include page="../includes/footer" />
</div></div>

		<jsp:include page="../includes/tracker" />
	</body>
</html>
